<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <?php
            echo $this->HeadTitle('Sysrubro');

            echo $this->HeadMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8');

            echo $this->HeadLink()->appendStylesheet('/ext/resources/css/ext-all.css')
                                  ->appendStylesheet('/css/layout.css');

            echo $this->HeadScript()->appendFile('/ext/adapter/ext/ext-base.js')
                                    ->appendFile('/ext/ext-all.js')
                                    ->appendFile('/js/global_layout.js')
                                    ->appendFile('/js/x_msg.js')
                                    ->appendFile('/js/x_form.js')
                                    ->appendFile('/js/x_grid.js')
                                    ->appendFile('/js/x_store.js')
                                    ->appendFile('/js/ext_egresocc_editar.js');
        ?>
    </head>
    <body>
        <table class="layout">
            <tr><td id="layout_header"></td></tr>
            <tr><td id="layout_menu"></td></tr>
            <tr><td id="layout_content"></td></tr>
            <tr><td id="layout_footer"></td></tr>
        </table>
    </body>
    <script type="text/javascript">
        Ext.onReady(function()
        {
            try{
                <?php X\MenuAdmin::Show(); ?>
                <?php  if ($this->error): ?>

                    <?php echo 'X.msg.FailureRedirect(' . json_encode($this->error) . ', "/egresocc/listar");'; ?>

                <?php else: ?>
                    store_organizacion.setJson('<?php echo X\Msg::Escape($this->jsonOrganizaciones); ?>');
                    store_cuenta      .setJson('<?php echo X\Msg::Escape($this->jsonCuentas);        ?>');
                    store_editor      .setJson('<?php echo X\Msg::Escape($this->jsonMovimientos);    ?>');
                    store_tipo        .setJson('<?php echo X\Msg::Escape($this->jsonTipos);          ?>');
                    
                    // correcccion de: el grid al editar muestra la representacion simbolica de los caracteres especiales
                    store_editor.each(function(rec, scope){
                        if(rec.get('observaciones')!=null)
                        rec.set('observaciones', rec.get('observaciones').replace(/&quot;/g, '"').replace(/&#39;/g, "'"));
                        if(rec.get('concepto')!=null)
                        rec.set('concepto', rec.get('concepto').replace(/&quot;/g, '"').replace(/&#39;/g, "'"));
                        rec.commit();
                    });
                    
                    Ext.getCmp('codigoComprobante').setValue('<?php echo X\Msg::EscapeField($this->comprobante->getCodigoComprobante()); ?>');
                    Ext.getCmp('fechaComprobante') .setValue('<?php echo X\Msg::EscapeField($this->comprobante->getFechaComprobante());  ?>');
                    Ext.getCmp('numeroComprobante').setValue('<?php echo X\Msg::EscapeField($this->comprobante->getNumeroComprobante()); ?>');
                    Ext.getCmp('organizacion')     .setValue('<?php echo X\Msg::EscapeField($this->comprobante->getOrganizacionesExternas()->getCodigoOrganizacion()); ?>');
                    Ext.getCmp('tipo')             .setValue('<?php echo X\Msg::EscapeField($this->comprobante->getDocumento()->getCodigoDocumento());   ?>');
                <?php endif; ?>
            }
            catch(e){
                X.msg.FailureJs(e.message);
            }
        });
    </script>
</html>


